<script setup>
import { ref, watch } from 'vue'
import { usePopStore } from '@/stores'
import { storeToRefs } from 'pinia'
import Detail from './DetailPop.vue'

const popStore = usePopStore()
const { Hangxian, XY } = storeToRefs(popStore)
const showDetail = ref(false)
const detail = ref(null)

const close = () => {
  Hangxian.value.showPop = false
}
const tasksType = ref({
  1: '文旅观光',
  2: '载人通勤',
  3: '物流运输',
  4: '政务巡检',
  5: '飞行验证'
})
const dialogPosition = ref([0, 0])
watch(
  Hangxian.value,
  (newVal) => {
    if (newVal) {
      dialogPosition.value = XY.value
    }
  },
  {
    deep: true
  }
)
// 点击查看气象信息图
const detailClick = () =>{
  detail.value.showFn(true)
}
</script>
<template>
  <transition
    appear
    name="custom-classes-transition"
    enter-active-class="animate__animated  animate__fadeIn"
    leave-active-class="animate__animated animate__faster  animate__fadeOut"
  >
    <div
      class="HangxianPop"
      ref="currentDom"
      v-drag
      :style="{
        left: dialogPosition[0] + 'px',
        top: dialogPosition[1] + 'px'
      }"
      v-if="Hangxian.showPop"
    >
      <p class="title">
        <span>航线信息</span>
        <span @click="close"><img src="@img/pop/close_icon.png" alt="" /></span>
      </p>
      <div class="content">
        <div class="left">
          <p>
            <span>· <i>航线名称</i>：</span>
            <el-tooltip effect="dark" :content="Hangxian.popInfo.airspaceName" placement="top">
              <span>{{ Hangxian.popInfo.airspaceName }}</span>
            </el-tooltip>
          </p>
          <p>
            <span>· <i>运营单位</i>：</span><span>{{ Hangxian.popInfo.运营单位 }}</span>
          </p>
          <p>
            <span>· <i>飞行器类型</i>：</span><span>{{ Hangxian.popInfo.飞行器类型 }}</span>
          </p>
          <p>
            <span>· <i>飞行器型号</i>：</span><span>{{ Hangxian.popInfo.飞行器型号 }}</span>
          </p>
          <p>
            <span>· <i>气象信息</i>：</span><span class="detail_btn" @click="detailClick">查看</span>
          </p>
        </div>
      </div>
    </div>
  </transition>
  <!-- 气象信息弹框 -->
  <Detail ref="detail" />
</template>
<style scoped lang="scss">
.HangxianPop {
  position: fixed;
  z-index: 9;
  top: 100px;
  right: 400px;
  width: 320px;
  padding-bottom: 10px;
  background: url('@img/pop/airspace_bg.png');
  background-size: 100% 100%;

  .title {
    display: flex;
    padding: 10px 20px 10px 50px;
    align-items: center;
    font-size: 16px;
    justify-content: space-between;

    span:last-child {
      width: 18px;
      height: 18px;
      cursor: pointer;

      img {
        width: 100%;
        height: 100%;
      }
    }
  }

  .content {
    margin-top: 5px;
    padding: 12px;
    display: flex;
    font-size: 13px;

    .left,
    .right {
      flex: 1;
      margin-left: 10px;

      p {
        padding: 5px 0;
        display: flex;
        align-items: center;
        span:first-child {
          flex: 0 0 100px;
          color: #afebff;
          display: flex;
          align-items: center;
          i {
            display: inline-block;
            width: 100%;
            margin: 0 3px;
            text-align-last: justify;
            text-align: justify;
            font-style: normal;
          }
        }

        span:last-child {
          flex: 1;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }

        &.name {
          font-size: 14px;
        }
      }
      .detail_btn {
        color: #00d5ff;
        text-decoration: underline;
        cursor: pointer;
        font-size: 16px;
      }
    }
  }
}
</style>
